import {defHttp} from "/@/utils/http/axios";
import {ErrorMessageMode} from "/#/axios";

import {
    EpibolyPersonDto, EpibolyPersonDtoListModel,
    EpibolyUnitDto,
    EpibolyUnitListModel,
    EpibolyUnitQueryConditionDto
} from "/src/api/ehs/model/epibolyModel";

enum Api{
    EpibolyUnitQuery = '/ehs/epibolyunit/query',
    EpibolyUnitAdd = '/ehs/epibolyunit/add',
    EpibolyUnitUpdate = '/ehs/epibolyunit/update',
    EpibolyUnitDelete = '/ehs/epibolyunit/delete',
    EpibolyUnitAddToBlackList = '/ehs/epibolyunit/blacklist',

    EpibolyPersonGetByUnit = '/ehs/epibolyperson/unit',
    EpibolyPersonAdd = '/ehs/epibolyperson/add',
    EpibolyPersonUpdate = '/ehs/epibolyperson/update',
    EpibolyPersonDelete = '/ehs/epibolyperson/delete',
    EpibolyPersonAddToBlackList = '/ehs/epibolyperson/blacklist',
}

/**
 * 查询相关方单位
 * @param params
 * @param mode
 */
export function queryEpibolyUnit(params: EpibolyUnitQueryConditionDto, mode: ErrorMessageMode = 'modal') {
    return defHttp.post<EpibolyUnitListModel>(
        {
            url: Api.EpibolyUnitQuery,
            data:params
        },
        {
            errorMessageMode: mode
        }
    );
}

/**
 * 添加相关方单位
 * @param params
 * @param mode
 */
export function addEpibolyUnit(params: EpibolyUnitDto, mode: ErrorMessageMode = 'modal') {
    return defHttp.post<string>(
        {
            url: Api.EpibolyUnitAdd,
            params
        },
        {
            errorMessageMode: mode
        }
    );
}

/**
 * 更新相关方单位
 * @param params
 * @param mode
 */
export function updateEpibolyUnit(params: EpibolyUnitDto, mode: ErrorMessageMode = 'modal') {
    return defHttp.post<string>(
        {
            url: Api.EpibolyUnitUpdate,
            params
        },
        {
            errorMessageMode: mode
        }
    );
}

/**
 * 删除相关方单位
 * @param id
 * @param mode
 */
export function deleteEpibolyUnit(id: string, mode: ErrorMessageMode = 'modal') {
    return defHttp.delete<string>(
        {
            url: Api.EpibolyUnitDelete,
            params: { id }
        },
        {
            errorMessageMode: mode,
            joinParamsToUrl:true
        }
    );
}

/**
 * 将相关方单位添加到黑名单
 * @param id
 * @param mode
 */
export function addEpibolyUnitToBlack(id: string, mode: ErrorMessageMode = 'modal') {
    return defHttp.post<string>(
        {
            url: Api.EpibolyUnitAddToBlackList,
            params: { id: id }
        },
        {
            errorMessageMode: mode,
            joinParamsToUrl:true
        }
    );
}

/**
 * 查询相关方人员（根据单位ID）
 * @param id
 * @param mode
 */
export function getEpibolyPersonByUnitId(id: string, mode: ErrorMessageMode = 'modal') {
    return defHttp.get<EpibolyPersonDtoListModel>(
        {
            url: Api.EpibolyPersonGetByUnit,
            params: { id }
        },
        {
            errorMessageMode: mode,
            joinParamsToUrl:true
        }
    );
}

/**
 * 添加相关方人员
 * @param params
 * @param mode
 */
export function addEpibolyPerson(params: EpibolyPersonDto, mode: ErrorMessageMode = 'modal') {
    return defHttp.post<string>(
        {
            url: Api.EpibolyPersonAdd,
            params
        },
        {
            errorMessageMode: mode
        }
    );
}

/**
 * 更新相关方人员
 * @param params
 * @param mode
 */
export function updateEpibolyPerson(params: EpibolyPersonDto, mode: ErrorMessageMode = 'modal') {
    return defHttp.post<string>(
        {
            url: Api.EpibolyPersonUpdate,
            params
        },
        {
            errorMessageMode: mode
        }
    );
}

/**
 * 删除相关方人员
 * @param id
 * @param mode
 */
export function deleteEpibolyPerson(id: string, mode: ErrorMessageMode = 'modal') {
    return defHttp.delete<string>(
        {
            url: Api.EpibolyPersonDelete,
            params: { id }
        },
        {
            errorMessageMode: mode,
            joinParamsToUrl:true

        }
    );
}

/**
 * 将相关方人员添加到黑名单
 * @param id
 * @param mode
 */
export function addEpibolyPersonToBlack(id: string, mode: ErrorMessageMode = 'modal') {
    return defHttp.post<string>(
        {
            url: Api.EpibolyPersonAddToBlackList,
            params: { id: id }
        },
        {
            errorMessageMode: mode,
            joinParamsToUrl:true
        }
    );
}

/**
 * 创建一个平台用户调用的接口提供给证照用于新增或者修改
 */
export function addEpibolyPersonForPlatform(params: EpibolyPersonDto, mode: ErrorMessageMode = 'modal') {}
